/**
 * Created by kevin on 2017/01/08.
 *
 * page base
 */


var eosi = window.eosi || {};
this.eosi.website = this.eosi.website || {};

(function (window) {
    // the application


    function BaseSpriteSheet(sp_img,draw_content) {
        this.sp_img=sp_img;
        this.draw_content=draw_content;
        this.Container_constructor();
        this.init();
        //console.log(this.father.targetWidth);

    }

    var p = createjs.extend(BaseSpriteSheet, createjs.Container);
    p.className = "BaseSpriteSheet";
    p.oriScale;
    p.huoju1;


    // public methods:
    p.init = function () {
        this.oriScale = this.scaleX;
        if (DEBUG) {
            //console.log(this.draw_content);
        }
        var spsh =this.Runimg(this.sp_img,this.draw_content.row,this.draw_content.cols,this.draw_content.w,this.draw_content.h,this.draw_content.loop_number);//暂时到这里 
        spsh.name="spsh"
        this.addChild(spsh);
    }
    p.Runimg=function(img,row,cols,w,h,loop_number){
        var jianju=0;
        var w=w;var h=h;var line_h=0+h;
        var frames = [
        ];
        for (var j=0; j <row; j++) {
            for (var i =0; i <cols; i++) {
                frames.push([i*(jianju+w),j*line_h,w,h]);
            }
        }
        var huoju_ss = new createjs.SpriteSheet({
            framerate: 10,
            "images": [img],
            frames: frames,
            "animations": {
                "wait": [0,0, "wait", 1],
                "torch": [0,loop_number-1, this.draw_content.EndAnimatiosName, 1],
                "stop": [loop_number-1,loop_number-1, "stop", 1],
            }
        });
        //var huoju1=new createjs.Bitmap(resLoader.getResult("huoju1"));
        var huoju1=new createjs.Sprite(huoju_ss,this.draw_content.StaetAnimatiosName);
        //huoju1.scaleX=huoju1.scaleY=this.ratio;
        return huoju1;
    }
    p.qiehuan=function(ev){
     this.getChildByName('spsh').gotoAndPlay("torch");
    }
    // add MyApp to myNameSpace
    window.eosi.website.BaseSpriteSheet = createjs.promote(BaseSpriteSheet, "Container");
//}());
}(window));





